const express = require('express')
const cors = require('cors')
const morgan = require('morgan')
const router = require('./router')
const errorHandler = require('./middleware/error-handler')
require('./model')

const PORT = process.env.PORT || 9000

const app = express()

app.use(morgan('dev'))

app.use(express.json())

app.use(cors())

app.use('/', router)

app.use(errorHandler())

app.post('/user/:userId', (req, res) => {
  console.log(req.query, req.params)
  res.send('/user/: ' + req.query)
})

app.listen(PORT, () => {
  console.log(PORT)
})
